<template>
  <su-popup
    :show="state.show"
    @close="onCancel"
    round="20"
  >
   <view class="ss-p-50 ss-p-y-100">
	   <view class="font-2 font-w ss-m-b-30">超引擎代金券配置抵扣金额</view>
	   <view class="ss-flex justify-between ss-p-y-12 bb">
		   <view class="font-2">购买金额</view>
		   <view class="disable">{{state.info.face_value}}</view>
<!-- 		   <input
			:disabled="true"
		     :inputBorder="false"
		     v-model="state.info.face_value"
		     placeholder="请输入购买金额"
		   /> -->
	   </view>
	   <view class="ss-flex justify-between ss-p-y-12">
	   		   <view class="font-2">抵扣金额</view>
	   		   <input
	   		     :inputBorder="false"
	   		     v-model="state.info.price"
	   		     placeholder="请输入抵扣金额"
	   		   />
	   </view> 
	   
	   <button @tap="confirm" class="btn ss-m-t-30">确认修改</button>
   </view>
  </su-popup>
</template>

<script setup> 
import throttle from '@/sheep/helper/throttle.js';
import {
  computed,
  reactive,
  onMounted,
  inject,
  ref,
  watch
} from 'vue';
import {
  onLoad
} from '@dcloudio/uni-app';
	import couponAPI from "@/ygb/api/coupon"
import {
  isEmpty
} from 'lodash';
import sheep from '@/sheep';
import data from '@/pages/etc/data';
const emits = defineEmits(['cancel', 'end']);
const props = defineProps({});
const state = reactive({
  show: false,
  info:{
	  face_value:50,
	  price:''
  }
});

const open = async () => {
	await getInfo()
  
  
}
 
async function confirm(){
	if(!state.info.price){
		uni.showToast({
			title:'请设置抵扣金额',
			icon:'none',
			duration:2000
		})
		return
	}
	
	const res = await couponAPI.ticket_set({price:state.info.price})
	if(res.error==0){
		uni.showToast({
			title:'设置成功',
			icon:'none', 
			duration:2000
		})
		state.show=false
	}
}
// 查询代金券
async function getInfo(){
	
	const res = await couponAPI.ticket_set()
	if(res.error==0){
		state.info=res.data
		state.show = true
	}
}
const onCancel = () => {
  state.show = false
};
defineExpose({
  open,
})
onMounted(async () => {
})
</script>

<style lang="scss" scoped>
	input {
	  padding-top: 12rpx;
	  font-size: 32rpx;
	  text-align: right;
	}
	.disable{
		
		font-size: 32rpx;
		
		color: #B2B2B2;
	
	}
	.font-w{
		font-weight: bold;
	}
	.bb{
		border-bottom: 2rpx solid #f7f7f7;
	}
	.btn{
		width: 648rpx;
		height: 80rpx;
		border-radius: 20rpx;
		color:#fff;
		font-size: 32rpx;
			
		background: linear-gradient(180deg, #FF41AE 0%, #BE00FF 100%);
	
	}
</style>